package kr.hkit.powerjava.chapter06;

public class GuguDanFor {
	public static void main(String[] args) {
/*		for(int i = 1; i<10; i++) {
			System.out.printf("%2d * %2d = %2d%n", 2 , i , 2*i);
		}*/

/*		for(int i=2;1<10;i++){
			int dan = 2;
			calGuguDan(dan); //dan으로 바꿔야하나?
		}*/
		
		
		for(int dan=2; dan<10; dan++){
			calGuguDan(dan);
		}
		
//		calGuGuDan();
		
//		calFact(5);
		
//		prnstar();
		
//		calGuguDan1(5);
		
//		prnstar2();
		
//		prnTriStar();
	}
	
	// 구구단만 정확하게 출력하세요!!!!!
	private static void prnTriStar() { //공백이랑 별표찍기 쌤 리뷰
		for (int i=6; i>0; i--){ 
			//공백출력
			for (int j=0; j<i-1; j++) {
				System.out.print(" ");
			}
			for (int j=i; j<6; j++) {
				System.out.print("*");
			}
			System.out.println();
			//별표출력
		}
	}


	private static void prnstar2() { //공백이랑 별표찍기 연습
		for(int i = 0 ; i < 5; i++) {
			for (int j = 0; j < 5-i; j++){ //이거빼면 그냥 왼쪽정렬.
				System.out.print(" ");
			}
			for (int j = 0; j < i+1; j++) {
				System.out.print("*");
			}
			System.out.println();
		}
	}


	private static void calGuguDan1(int dan) {
		for(int i=1; i<10; i++) {
			if (i==5) continue; //5를 만나면 건너뛰세요
			System.out.printf("%2d * %2d = %2d%n", dan, i ,dan*i);
		}
		System.out.println();
	}

	
	
	private static void prnstar() {
		for (int j=0; j<10; j++) {
			for (int i=0; i<10; i++) {
				System.out.print("*");
			}
			System.out.println();
		}
	}
	
	
	private static void calFact(int i) {
		int fact=1; //5팩토리얼 구하기
		
		for (int j=1; j<i+1; j++){
			fact = fact * j;
		}
		System.out.println(i + "! = " + fact );
	}

	private static void calGuGuDan() {
		for(int dan=2; dan<10; dan++){
			for(int i=1; i<10; i++) {
				System.out.printf("%2d * %2d = %2d%n", dan, i ,dan*i);
		}
		System.out.println();
		}
	}

	private static void calGuguDan(int dan) {
		for(int i=1; i<10; i++) {
			System.out.printf("%2d *%2d = %2d%n", dan, i ,dan*i);
		}
		System.out.println();
	}
}
